<template>
  <div>
    <h1>
      重写表格的checkbox接入elementUI的checkbox，基于现在api只能实现UI不能修改绑定字段变成其他的值，不然都会有错误
    </h1>
    <EditDynamicTable
      ref="EditDynamicTable"
      :data="tableData"
      keep-source
      :checkbox-config="{checkField: 'checkbox'}"
      :table-config="tableConfig2"
    >
    </EditDynamicTable>
  </div>
</template>

<script>
import {TableConfig} from "@localModules/ZhiXinLib/vxeTable-components/edit-dynamic-table/TableType";
import {strCopyCount} from "@localModules/ZhiXinLib/utils";
import ShowTooltip from "@localModules/ZhiXinLib/directive/VshowTooltip/VshowTooltip";
import {ClickCopy} from "@localModules/ZhiXinLib/directive/ClickCopy";

export default {
  name: "index",
  components:{
    EditDynamicTable:()=>import('@localModules/ZhiXinLib/vxeTable-components/edit-dynamic-table/index')
  },
  directives:{
    ShowTooltip,
    ClickCopy
  },
  data(){
    return {
      setOptions:[],
      currentPage4: 10,
      tableConfig2: new TableConfig({}, [
        {
          label: '序号',
          type: 'index'
        },
        {
          type: 'checkbox',
        },
      ]),
    }
  },
  computed:{
    tableData(){
      const data = [
      ]
      for (let i = 0; i < 10; i++) {
        data.push({
          checkbox: i%2===0,
          genProp0: '66' + this.currentPage4,
          genProp1: '66' + this.currentPage4,
          genProp2: '7383.38' + this.currentPage4,
          genProp3: strCopyCount('1119.59',this.currentPage4) + this.currentPage4,
          asyncTest: 'value1'
        })
      }
      return data
    }
  },
  mounted() {
    setTimeout(()=>{
      this.setOptions=[
        {
          label: 'label1',
          value: 'value1'
        },
        {
          label: 'label2',
          value: 'value2'
        },
      ]
    },1000)
  },
  methods: {
    rules() {
      this.$refs.EditDynamicTable.validate().then(errMap=>{
        console.log(errMap)
      })
    }
  }
}
</script>

<style scoped lang="scss">
.test{
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
</style>
